package surreal.triviamaster.gui;

import surreal.triviamaster.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Correct extends Activity{
	private boolean isQuizOver;

	@Override
	  public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.correct);
	    
	    //handles changing orientation
    	final Bundle data = (Bundle) getLastNonConfigurationInstance();
    	if(data!=null) {
    		isQuizOver=data.getBoolean("isQuizOver");
    	} else {
    		isQuizOver = getIntent().getExtras().getBoolean("isQuizOver");
    	}
    	
    	if(isQuizOver) {
    		((Button) findViewById(R.id.nextQuestion)).setText("See Results");
    	}
	    
    	//next questions button
	    Button flagAnswer = (Button) findViewById(R.id.nextQuestion);
	    flagAnswer.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	Intent intent = new Intent(Correct.this, Game.class);
	  	      	startActivity(intent);
            }
        });
	}
	
	@Override
	public void onBackPressed() {
	   return;
	}
	
	@Override
	public Bundle onRetainNonConfigurationInstance() {
		Bundle bundle = new Bundle();
		bundle.putBoolean("isQuizOver", isQuizOver);
	    return bundle;
	}
}
